var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },


  onLoad: function (options) {
    var yz_id = options.id;
    this.setData({
      yz_id:yz_id
    })
    this.getYanzhiInfo();
  },

  getYanzhiInfo:function(){
    var t = this;
    app.visit("huodong/getBaWangInfo", {
      yz_id:t.data.yz_id,
    }, "", function(c) {
      console.log(c)
      if(0 == c.code){
        t.setData({
          info:c.data,
          lj_start_price:c.data.lj_start_price,
          lj_end_price:c.data.lj_end_price,
          discount:c.data.discount
        })
      }else{
        app.showToast(c.msg)
      }
    })
  },

  setStart:function(e){
    this.setData({
      lj_start_price:e.detail.value
    })
  },

  setEnd:function(e){
    this.setData({
      lj_end_price:e.detail.value
    })
  },

  setDiscount:function(e){
    this.setData({
      discount:e.detail.value
    })
  },

  tijiao:function(e){
    var t = this;
    if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.lj_start_price))) {
      app.myToast("价格只能输入数字！")
    }else if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.lj_end_price))) {
      app.myToast("价格只能输入数字！")
    }else if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.discount))) {
      app.myToast("折扣只能输入数字！")
    }else{
      app.visit("huodong/setBaWangInfo", {
        yz_id:t.data.yz_id,
        lj_start_price:t.data.lj_start_price,
        lj_end_price:t.data.lj_end_price,
        discount:t.data.discount
      }, "", function(c) {
        console.log(c)
        if(0 == c.code){
          wx.showToast({
            title: '修改成功',
            icon: 'none',
            success: function () {
              wx.navigateBack();
            }
          })
        }else{
          app.showToast(c.msg)
        }
      })
    }
  },

})